An iterator of the columns of the array.
int[][] nums = [[1, 2], [10, 20]] assert nums.transpose() == nums.columns().toList() assert nums.columns().collect{ int[] col -> col.sum() } == [11, 22]
Flattens a 2D array into a new collection. The items are copied row by row.
Example usage:
int[][] array = [[0, 1], [2, 3]] assert array.flatten() == [0, 1, 2, 3]
A transpose method for 2D int arrays.
Example usage:
int[][] nums = [[10, 15, 20], [30, 35, 40]] int[][] expected = [[10, 30], [15, 35], [20, 40]] assert nums.transpose() == expected